﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Conis.Squirrel.SqlBuilder;
using System.Data.OracleClient;
using Conis.Squirrel;

/*
 * Author:Conis
 * Date:
 * Description:SQL操作工厂
 */

namespace Conis.Squirrel.SqlBuilder.Oracle
{
    public class SqlFactory : BaseSqlFactory
    {
        public SqlFactory(string connectionString) : base(connectionString) { }

        /// <summary>
        /// 获取一个执行SQL的实现类
        /// </summary>
        /// <returns></returns>
        protected override BaseExecuteSql GetExecuteSql()
        {
            return new ExecuteSql(this.Connection as OracleConnection, this.Transaction as OracleTransaction);
        }

        /// <summary>
        /// 获取一个连接对象
        /// </summary>
        /// <returns></returns>
        protected override System.Data.IDbConnection GetConnection()
        {
            return new OracleConnection(this.ConnectionString);
        }

        /// <summary>
        /// 获取一个条件实现类
        /// </summary>
        /// <returns></returns>
        protected override BaseCondition GetCondition()
        {
            return new Condition();
        }

        /// <summary>
        /// 获取一个排序实现类
        /// </summary>
        /// <returns></returns>
        protected override BaseOrderBy GetOrderBy()
        {
            return new OrderBy();
        }

        /// <summary>
        /// 获取一个数据访问实现类
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="primaryKey"></param>
        /// <returns></returns>
        protected override BaseDataAccess GetDataAccess(string tableName, string primaryKey)
        {
            return new DataAccess(this, tableName, primaryKey);
        }
    }
}
